using UnityEngine;
using System.Collections;

/// \class  gkInitialPositionOnCylinderTube
/// \brief  Constraint the actor to a certain radius on cylindrical position corresponding to the cylinder tue infos
[AddComponentMenu("GK/Engine/Game/CylinderTube/gkInitialPositionOnCylinderTube")]
[RequireComponent(typeof(gkCylindricalPosition))]
public class gkInitialPositionOnCylinderTube : MonoBehaviour 
{
    /// \brief  Called just after the game begin to play
    void Start()
    {
	    gkCylinderTubeInfo rCylinderTubeInfo;
		gkCylindricalPosition rCylindricalPosition;
	    Vector3 f3OwnerCylindricalPosition;

        // Grab the cylinder tube info
		rCylinderTubeInfo = GameObject.Find("CylinderTubeInfo").GetComponent<gkCylinderTubeInfo>();
		
		// Grab the cylindrical position
		rCylindricalPosition = GetComponent<gkCylindricalPosition>();
		
	    // Set the radius position of the owner
	    f3OwnerCylindricalPosition = rCylindricalPosition.position;
		
	    f3OwnerCylindricalPosition.x = rCylinderTubeInfo.GetRadius();
	    
		rCylindricalPosition.position = f3OwnerCylindricalPosition;
    }
}
